function ajax(success=true) {
    return new Promise((resolve,reject)=>{
        setTimeout(()=>{
            if(success){
                resolve('Ajax data.');
            }else{
                reject('Ajax error.');
            }
        },Math.random()*100|0);
    });
}


test('resolves',()=>{
    return expect(ajax()).resolves.toBe('Ajax data.');
});

test('rejects',()=>{
    return expect(ajax(false)).rejects.toMatch('Ajax error.');
});